package com.ruoyi.leader.api.factory;

import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.leader.api.RemoteLeaderService;
import com.ruoyi.leader.api.domain.TGroupLeader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 团长服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteLeaderFallbackFactory implements FallbackFactory<RemoteLeaderService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteLeaderFallbackFactory.class);

    @Override
    public RemoteLeaderService create(Throwable throwable)
    {
        log.error("团长服务调用失败：{}", throwable.getMessage());
        return new RemoteLeaderService()
        {
            @Override
            public R<Boolean> addLeader(TGroupLeader tGroupLeader, String source)
            {
                return R.fail("新增团长失败：" + throwable.getMessage());
            }
        };
    }
}

